//用户认证的中间件
const auth = (req,res,next)=>{
    if(req.session.userInfo){
        //有登录
        req.userInfo = req.session.userInfo
        next()
    }else{
        //乖乖去登录页面
        res.redirect(`/login?redirect=${req.originalUrl}`)
    }
}
module.exports = auth